// 发送ajax请求
import config from './config'
export default (url,num,data={},method='GET')=>{
    return new Promise((resolve,reject)=>{
         wx.request({
            url: config.host[num] + url,
            data,
            header: {cookie: wx.getStorageSync('cookies')?wx.getStorageSync('cookies').find(item => item.indexOf('MUSIC_U') !== -1):''},
            method,
            success: (res)=>{
                //判断是否为登录页面
                if(data.isLogin){
                    wx.setStorageSync('cookies', res.cookies);
                }
                resolve(res.data)
            },
            fail: (err)=>{
                reject(err)
            },
        });
    })
}